<style scoped>
  .goback {
    font-size: 16px;
    font-family: PingFangSC-Regular;
    color: rgba(255, 255, 255, 1);
    padding: 12px 0;
    width: 80%;
    margin: 0 auto;
    border: none;
    border-radius: 5px;
    margin-top: 50px;
  }
  .van-cell__title{
    color: #636363;
      
  }
  .van-nav-bar .van-icon{
      color: white;
  }
  .van-nav-bar__left .van-nav-bar .van-icon{
    color: white;
  }
  .van-cell{
    display: -webkit-box;
  }
</style>

<template>

  <div>
    <div v-wechat-title="$route.meta.title"></div>
    <div style="height:20px;"></div>
    <div class="payWarp">
      <van-cell title="交易信用卡" is-link @click="cctc=true">
          <span v-if="defcc">
            <img :src="defcc.bankCode | fmtccbank" style=" width: 17px;  margin-right: 4px;  position: relative; top: 3px;">{{ defcc.bankCode | fmtscname}}（{{defcc.bankCard |fmtsccardno}}） 
          </span>
          <span v-else>请选择交易信用卡</span>
      </van-cell>
      <van-cell v-if="sclist" title="到账储蓄卡" is-link >
        <span v-if="defsc" @click="sctc = true">
          <img :src="defsc.bankCode | fmtccbank" style="width: 17px;  margin-right: 4px;  position: relative; top: 3px;"/>{{ defsc.bankCode | fmtscname }}（{{defsc.bankCard |fmtsccardno}}）
        </span>
        <span v-else @click="sctc = true">请选择到账储蓄卡</span>
      </van-cell>

      <van-row>
        <van-col span="18" class="sele">交易金额</van-col>
        <van-col span="20" class="sele bob1 p0" style="padding: 0px 0 15px 30px;">
          <span>￥
            <input class="mout" type="number" oninput="this.value=this.value.replace(/[^0-9]+/,'');" v-model="amount" v-on:input="change" placeholder="请输入金额">
          </span>
          <hr class="bortop1" v-if="bortop1">
          <hr class="bortop2" v-if="bortop1==false">
        </van-col>
        <van-col span="18" class="sele" style="color:#CF3A3A;padding: 0px 0 15px 30px;font-size:14px;">
          <p v-if="amount>pw.maxAmount/100">交易金额不能大于{{pw.maxAmount/100}}</p>
          <p v-else-if='amount<pw.minAmount/100'>交易金额不能小于{{pw.minAmount/100}}</p>
        </van-col>
      </van-row>
      <div class="cb"></div>
    </div>
    <div style="width:100%;text-align: center;">
        <button class="goback" style="background:rgba(89,143,225,1);" @click="pay">提交</button>
    </div>
    <van-popup v-model="cctc" position="top" :overlay="true">
      <ul>
        <div style="padding:20px;font-size:16px;">
          请选择交易信用卡
        </div>
        <li v-for="(cccar,index) in cclist" :key="index" class="bortop1" style="padding:5px  20px;letter-spacing:1px;" @click="ccok(cccar)">
          <van-row v-if="cccar.isshowtrue">
            <van-col span="3">
              <img :src="cccar.bankCode | fmtccbank" alt="" width="100%">
            </van-col>
            <van-col span="18" class="cccarlist">
              <p>{{cccar.bankCode | fmtscname}}</p>
              <p>{{cccar.bankCard | fmtcardnomi}}</p>
            </van-col>
          </van-row>
          <van-row v-else style="opacity: .3;">
            <van-col span="3">
              <img :src="cccar.bankCode | fmtccbank" alt="" width="100%">
            </van-col>
            <van-col span="10" class="cccarlist">
              <p>{{cccar.bankCode | fmtscname}}</p>
              <p>{{cccar.bankCard | fmtcardnomi}}</p>
            </van-col>
             <van-col span="7" style="position: relative; top: .4rem;font-size:12px;text-align: right;" >
              <p>暂不支持</p>
            </van-col>
          </van-row>
        </li>
      </ul>
    </van-popup>

    <van-popup  v-model="sctc" position="top" :overlay="true">
      <ul>
        <div style="padding:20px;font-size:16px;">
          请选择到账储蓄卡
        </div>
        <li v-for="(cccar,index) in sclist" :key="index" class="bortop1" style="padding:5px  20px;letter-spacing:1px;" @click="scok(cccar)">
          <van-row>
             <van-col span="3">
              <img  :src="cccar.bankCode | fmtccbank" alt="" width="100%">
            </van-col>
            <van-col span="18" class="cccarlist">
              <p>{{cccar.bankCode | fmtscname}}</p>
              <p>{{cccar.bankCard | fmtcardnomi}} </p>
            </van-col>
           
          </van-row>
        </li>
      </ul>
    </van-popup>

    <div id="allmap"></div> 
  </div>

</template>

<script>
import imgse from '../img/qitayinhang.png';
var $th ="";
  import {
    Row,
    Col
  } from 'vant';
  import {
    Toast
  } from 'vant';
  export default {
    data() {
      return {
        // host: 'http://47.104.25.147:1188',
        host: this.GLOBAL.host,
        // host:'http://192.168.1.187/yj-epos',
        // host:'http://192.168.1.117:8034',
        cctc: false,
        sctc: false,
        sclist: [],  //储蓄卡
        cclist: [], //信用卡
        defcc: '',
        defsc: '',
        pw: this.GLOBAL.pw,
        amount: "",   //自己输入的交易金额
        bortop1:true,
        count:1,//用于判断是否换卡
        point:{  //百度地图
            lng:'',
            lat:''
        },
      };
    },
  

    
    created: function () {
      // console.log(this.defcc.cardNumber)
      Toast.loading({
        mask: true,
        message: '加载中'
      });
      this.FindCc();
      this.FindScTd();
      $th = this;
      console.log(this.GLOBAL.pw)
      
    },
    mounted: function () {
      // alert(123)
      var self = this
      var map = new BMap.Map("allmap");
      var point = new BMap.Point(116.331398,39.897445);  //
      
      map.centerAndZoom(point,12);
      function myFun(result){
        console.log(result)
          var cityName = result.name;
          map.setCenter(cityName);
          // console.log(result.center.lat)
          // alert("当前定位城市:"+cityName);
          self.point.lng=result.center.lng.toFixed(2)
          self.point.lat=result.center.lat.toFixed(2)
          // console.log(self.point)
      }
      var myCity = new BMap.LocalCity();
      console.log(myCity)
      myCity.get(myFun);
    },

    methods: {
      
      //监听input框中输入的值
      change(){
        console.log(this.pw.maxAmount/100)
        if(this.amount > this.pw.maxAmount/100 || this.amount < this.pw.minAmount/100){
          this.bortop1=false
        }else{
          this.bortop1=true
        }
      },
      
      FindCc() {
        axios //查询信用卡
            .get(this.host + "/bankCard/findList", {
            params: {
              type: "2", //1.储蓄  2.信用
              id: this.GLOBAL.id,
            }
          })
          .then(res => {
            // console.log(res.data)
            //  alert(JSON.stringify(res))
            if (res.data.code == "0000") {
              // console.log(res.data.data)
              if(res.data.data!=null){
                this.cclist = res.data.data;
                this.defcc = this.cclist[0];
                var mccname = {
                  ICBC: "工商银行",  
                  ABC: "农业银行",  
                  BOC: "中国银行",   
                  CCB: "建设银行",   
                  CMBCHINA: "招商银行",  
                  POST: "邮政储蓄",  
                  ECITIC: "中信银行",  
                  CEB: "光大银行",   
                  BOCO: "交通银行",  
                  CIB: "兴业银行",   
                  CMBC: "民生银行",  
                  PINGAN: "平安银行",  
                  CGB: "广发银行",   
                  HXB: "华夏银行",   
                  SPDB: "浦发银行",  
                  SHB: "上海银行",   
                  BCCB:"北京银行",   
                }
                for(let i=0;i<this.cclist.length;i++){
                    if(mccname[this.cclist[i].bankCode]==undefined){
                       this.cclist[i].isshowtrue=false
                    }else{
                       this.cclist[i].isshowtrue=true
                    }
                }
                // console.log('111',this.cclist)
              }
              Toast.clear();
            } else {
              Toast.clear();
              Toast(res.data.msg);
            }
          });
      },
      FindScTd() {
        axios.get(this.host + "/bankCard/findList", {   //查询卡集合
          params: {
              type: "1", //1.储蓄  2.信用
              id: this.GLOBAL.id,
          }
        }).then(res => {
          if (res.data.code == "0000") {
            var list=[]
            list = res.data.data;
            axios.get(this.host + '/bind/findBind', { //查询有没有绑卡绑卡
              params: {
                id: this.GLOBAL.id,
              }
            }).then(res => {
              if (res.data.code == "0000") {
                // console.log('1111',this.defsc)
                Toast.clear();
                // console.log(res.data.data)
                if(res.data.data!=null){
                  // console.log("111",list)
                  this.sclist = list;
                  this.count=0; //判断卡集合
                  for(let i=0;i<list.length;i++){
                    if(list[i].bankCard==res.data.data.cardNumber){
                      this.count += 1
                      this.defsc = list[i];
                      return
                    }
                  }
                  // console.log('count',this.count)
                  if(this.count==0){
                      this.count=0;
                      this.defsc=''
                      return
                  }
                  
                }else{
                  this.sclist = list;
                  this.count=-1;
                }
              }else{
                Toast.clear();
                Toast(res.data.msg);
              }
            })
            Toast.clear();
          } else {
            Toast.clear();
            Toast(res.data.msg);
          }
        });
        
             
      },
      //选择信用卡
      ccok(cccar) {
        // console.log(q123123)
        //如果是不支持此卡，点击没反应
        if(cccar.isshowtrue == false){
          return 
        }
        this.cctc = false;
        this.defcc = cccar;
        // console.log(this.defcc.issuingBank)

      },

      //请选择交易储蓄卡
      scok(cccar) {
        console.log('222',cccar)
        // console.log(q123123)
        this.defsc = cccar;
        if(this.count != -1){
          Toast.loading({
            mask: true,
            message: '加载中',
          });
          axios.get(this.host + '/bind/findBindAisle', {   //通道绑卡状态
            params: {
              id: this.GLOBAL.id,
            }
          }).then(res => {
              if (res.data.code == "0000") {
                console.log(res.data.data.settleBankAccountNo)
                console.log(cccar.bankCard)
                //判断两张卡号是否一致
                if(cccar.bankCard!=res.data.data.settleBankAccountNo){
                  axios.post(this.host + '/bind/updateDebitCard', this.$qs.stringify({
                      id: this.GLOBAL.id,
                      aisleMerId:res.data.data.merchantNo ,  //通道商户号
                      debitCardNo:cccar.bankCard,  //新卡号
                      debitCardPhone:cccar.reservePhone,  //新卡预留手机
                      debitCardBankCode:cccar.bankCode,//新卡银行标识
                      // debitCardBankName:this.defsc.bank,
                  }) //换卡
                  ).then(res => {
                    if (res.data.code == "0000") {
                      // console.log(res.data.data)
                      Toast.clear();
                    }else{
                      Toast.clear();
                      return this.$toast(res.data.msg);
                    }
                  }) 
                }
              } else{
               Toast.clear();
              return this.$toast(res.data.msg);
            }
          })
        }
        // issuingBankCode,//新卡银行标识
        // phone
        // cardNumber
        this.sctc = false;
        this.defsc = cccar;
       
        
      },
     
      pay() {
        // console.log(this.GLOBAL.aisleMerId)
        
        // this.$router.push({
        //     name:'CollectionRecords'
        // })
        // return
        let self = this;
        console.log(this.defsc)
        if(this.defsc == '' || this.defsc == null || this.defsc == undefined){
          return this.$toast( "获取信息异常，请返回后重试" )
        }
        // console.log(self.pw)
        // console.log(self.pw.minAmount)
        // console.log(this.pw.minAmount)
        // console.log(self.amount)
        if (
          self.pw.minAmount > self.amount * 100 ||
          self.amount * 100 > self.pw.maxAmount
        ) {
          Toast(
            "金额须在" +
            this.pw.minAmount / 100 +
            "-" +
            this.pw.maxAmount / 100 +
            "之间"
          );
          return;
        }
        if(this.defsc.bankCode==null || this.defsc.bankCode==''){
          this.defsc.bankCode = "other"
        }
        if(this.defsc.bank == null || this.defsc.bank == ''){
          this.defsc.bank = '其他'
        }
        var merchantNo=''  //通道商户号
        console.log(this.defsc)
        var queren={}
        Toast.loading({
          mask: true,
          message: '第一次加载时候较长，请耐心等待',
          duration:0,
    
        });
        axios.get(this.host + '/bind/findBind', { //查询绑卡
          params: {
            id: this.GLOBAL.id,
          }
        }).then(res => {
          if (res.data.code == "0000") {
            // return
            if(res.data.data==null ){
              //判断有没有换卡
              axios.post(this.host + '/bind/bind', this.$qs.stringify({   //绑卡开户
                  id: this.GLOBAL.id,
                  debitCardNo:this.defsc.bankCard,  //
                  debitCardPhone:this.defsc.reservePhone,
                  debitCardBankCode:this.defsc.bankCode,
                  debitCardBankName:this.defsc.bank,
              })).then(res => {
                if (res.data.code == "0000") {
                  merchantNo=res.data.data.merchantNo
                  axios.get(this.host + '/Information/select', {   //查询用户图片
                    params: {
                      id: this.GLOBAL.id,
                    }
                  }).then(res => {
                    if (res.data.code == "0000") {
                      if(res.data.data==null){
                        Toast.clear();
                        return this.$toast('查询不到图片');
                      }else{
                        console.log(123)
                        let img=[]
                        img.push(res.data.data.userIDCardA)
                        img.push(res.data.data.userIDCardB)
                        img.push(res.data.data.cardImgA)
                        img.push(res.data.data.faceImg)
                        if(res.data.data.userIDCardA == null || res.data.data.userIDCardB == null || res.data.data.cardImgA == null || res.data.data.faceImg ==null){
                            Toast.clear();
                            return this.$toast('资料信息异常，请联系客服')
                        }
                        axios.post(this.host + '/bind/uploadImg', this.$qs.stringify( {   //提交资质接口
                            id: this.GLOBAL.id,
                            aisleMerId:merchantNo,  //通道商户号
                            imgUrl:img[0],  //图片地址
                            imgType:'FRONT_ID_CARD_PHOTO',
                        })).then(res => {
                        
                          if (res.data.code == "0000") {
                            axios.post(this.host + '/bind/uploadImg', this.$qs.stringify( {   //提交资质接口
                                id: this.GLOBAL.id,
                                aisleMerId:merchantNo,  //通道商户号
                                imgUrl:img[1],  //图片地址
                                imgType:'BACK_ID_CARD_PHOTO',
                            })).then(res => {
                              if (res.data.code == "0000") {
                                axios.post(this.host + '/bind/uploadImg',  this.$qs.stringify({   //提交资质接口
                                    id: this.GLOBAL.id,
                                    aisleMerId:merchantNo,  //通道商户号
                                    imgUrl:img[2],  //图片地址
                                    imgType:'BANK_CARD_IMG',
                                })).then(res => {
                                  if (res.data.code == "0000") {
                                    axios.post(this.host + '/bind/uploadImg',  this.$qs.stringify({   //提交资质接口
                                        id: this.GLOBAL.id,
                                        aisleMerId:merchantNo,  //通道商户号
                                        imgUrl:img[3],  //图片地址
                                        imgType:'HAND_ID_CARD_PHOTO',
                                    })).then(res => {
                                      if (res.data.code == "0000") {
                                        let seft=this
                                        
                                        setTimeout(()=>{
                                          Toast.clear();
                                        },1000)
                                        let second = 10;
                                        var Interval = setInterval(function(){
                                          Toast.loading({
                                            duration: 0,       // 持续展示 toast
                                            forbidClick: true, // 禁用背景点击
                                            message: '等待开户结果'+second+'秒',
                                          });
                                          second--
                                          axios.get(seft.host + '/bind/findBindAisle', {   //通道绑卡状态
                                            params: {
                                              id: seft.GLOBAL.id,
                                            }
                                          }).then(res => {
                                            if (res.data.code == "0000") {
                                              if(res.data.data!=null){
                                                if(res.data.data.accessStatus=='COMPLETED'){
                                                  clearInterval(Interval)
                                                   // Toast.clear();
                                                    // queren={
                                                    //     amount:this.amount,
                                                    //     scard:this.defsc,  //储蓄卡
                                                    //     ccard:this.defcc,//信用卡
                                                    //     merchantNo:merchantNo,
                                                    // }
                                                    seft.GLOBAL.queren=seft.amount
                                                    axios.get(seft.host + '/bind/seleteRate',{  //获取费率
                                                        params: {
                                                            id:seft.GLOBAL.id,
                                                            productldentif:'PNS66'
                                                        }
                                                    }
                                                    ).then(res => {
                                                        if (res.data.code == "0000") {
                                                            if(res.data.data != null){
                                                                var dofee=res.data.data.singlePrice
                                                                axios.post(seft.host + '/bind/updateRate', seft.$qs.stringify({   //更新费率
                                                                    aisleMerId:merchantNo,
                                                                    rate:res.data.data.rate,
                                                                    bankCode:seft.defcc.bankCode,
                                                                    amount:seft.GLOBAL.accMul(seft.amount,100),
                                                                    productldentif:"PNS66"//PNS66   productIdfin
                                                                })
                                                                ).then(res => {
                                                                    if (res.data.code == "0000") {
                                                                        axios.post(seft.host + '/bind/updateD0fee', seft.$qs.stringify({   //更新 D0 费率
                                                                            aisleMerId:merchantNo,
                                                                            d0Fee:dofee,
                                                                        })).then(res => {
                                                                            if(seft.defcc.bank=='' || seft.defcc.bank==null || seft.defcc.bank==undefined){
                                                                              seft.defcc.bank='其他银行'
                                                                            }
                                                                            if (res.data.code == "0000") {
                                                                                axios.post(seft.host + '/order/pay', seft.$qs.stringify({   //支付
                                                                                    frontCallBackUrl:'https://community.1818pay.cn:1181/yj-jpos/location.html',
                                                                                    // frontCallBackUrl:'www.baidu.com'
                                                                                    lng:seft.point.lng,//精度   //'116.40'
                                                                                    lat:seft.point.lat,//维度   //'39.90'
                                                                                    aisleMerId: merchantNo , 
                                                                                    id:seft.GLOBAL.id,
                                                                                    productldentif:"PNS66",
                                                                                    amount:seft.GLOBAL.accMul(seft.amount,100),
                                                                                    creditCardNo:seft.defcc.bankCard,  //
                                                                                    creditPhone:seft.defcc.reservePhone,  //
                                                                                    creditCardCode:seft.defcc.bankCode,  //
                                                                                    creditCardName:seft.defcc.bank,    //卡归属银行
                                                                                })).then(res => {
                                                                                    if (res.data.code == "0000") {
                                                                                        Toast.clear();
                                                                                        window.location=res.data.data.url.payUrl
                                                                                        // this.GLOBAL.orderNo=res.data.data.orderNo
                                                                                        // // if(this.GLOBAL.terminal == 'iOS' ){
                                                                                        // //     window.location=res.data.data.url.payUrl
                                                                                        // // }else{
                                                                                        //     this.GLOBAL.payUrl=res.data.data.url.payUrl
                                                                                        //     this.$router.push({
                                                                                        //         name:'qrcode'
                                                                                        //     })
                                                                                        // // }
                                                                                    }else{
                                                                                        Toast.clear();
                                                                                        return Toast(res.data.msg);
                                                                                    }
                                                                                }).catch(err=>{
                                                                                    Toast.clear();
                                                                                    return Toast('请求超时');
                                                                                })
                                                                            }else{
                                                                                Toast.clear();
                                                                                return Toast(res.data.msg);
                                                                            }
                                                                        }).catch(err=>{
                                                                            Toast.clear();
                                                                            return Toast('请求超时');
                                                                        })
                                                                    }else{
                                                                        Toast.clear();
                                                                        return Toast(res.data.msg);
                                                                    }
                                                                }).catch(err=>{
                                                                    Toast.clear();
                                                                    return Toast('请求超时');
                                                                })
                                                            }else{
                                                                Toast.clear();
                                                                return Toast('请求超时');
                                                            }
                                                        }else{
                                                            Toast.clear();
                                                            return Toast(res.data.msg);
                                                        }
                                                    }).catch(err=>{
                                                        Toast.clear();
                                                        return Toast('请求超时');
                                                    })
                                                }
                                              }
                                              if(second == 0){
                                                clearInterval(Interval)
                                                Toast.clear();
                                                return Toast('获取数据失败，请稍后再试');
                                              }
                                            }
                                          }).catch(err=>{
                                            if(second == 0){
                                              clearInterval(Interval)
                                              Toast.clear();
                                              return Toast('获取数据失败，请稍后再试');
                                            }
                                          })
                                        },1000)
                                      }else{
                                          Toast.clear();
                                          return this.$toast(res.data.msg);
                                      }
                                    }).catch(err=>{
                                      Toast.clear();
                                      return this.$toast('资质上传失败，请重试')
                                    })
                                  }else{
                                      Toast.clear();
                                      return this.$toast(res.data.msg);
                                  }
                                }).catch(err=>{
                                  Toast.clear();
                                  return this.$toast('资质上传失败，请重试')
                                })
                              }else{
                                  Toast.clear();
                                  return this.$toast(res.data.msg);
                              }
                            }).catch(err=>{
                              Toast.clear();
                              return this.$toast('资质上传失败，请重试')
                            })
                          }else{
                              Toast.clear();
                              return this.$toast(res.data.msg);
                          }
                        }).catch(err=>{
                          Toast.clear();
                          return this.$toast('资质上传失败，请重试')
                        })                      
                      }
                    }else{
                      Toast.clear();
                      return this.$toast(res.data.message);
                    }
                  }).catch(err=>{
                    Toast.clear();
                    return this.$toast('请求超时')
                  })
                }else{
                  Toast.clear();
                  return this.$toast(res.data.msg);
                }
              }).catch(err=>{
                Toast.clear();
                return this.$toast('请求超时')
              })
              
            }else{
              console.log(res.data.data)
              axios.get(this.host + '/bind/findBindAisle', {   //通道绑卡状态
                params: {
                  id: this.GLOBAL.id,
                }
              }).then(res => {
                if (res.data.code == "0000") {
                  merchantNo=res.data.data.merchantNo
                  var settleBankAccountNo=res.data.data.settleBankAccountNo
                  console.log(settleBankAccountNo)
                  console.log(this.defsc.bankCard)
                  if(res.data.data.accessStatus=='COMPLETED'){
                    console.log(this.defsc.bankCard)
                    if(settleBankAccountNo!=this.defsc.bankCard){   //判断两个卡号是否一样
                      axios.post(this.host + '/bind/updateDebitCard', this.$qs.stringify({   //更改储蓄卡
                          id: this.GLOBAL.id,
                          aisleMerId:merchantNo,  //通道商户号
                          debitCardNo:this.defsc.bankCard,  //新卡号
                          debitCardPhone:this.defsc.reservePhone,  //新卡预留手机
                          debitCardBankCode:this.defsc.bankCode,//新卡银行标识
                      })).then(res => {
                        if (res.data.code == "0000") {
                          //  queren={
                          //     amount:this.amount,
                          //     scard:this.defsc,  //储蓄卡
                          //     ccard:this.defcc,//信用卡
                          //     merchantNo:merchantNo,
                          // }
                          this.GLOBAL.queren=this.amount
                          // this.$router.push({
                          //     name:'queren',
                             
                          // })
                          axios.get(this.host + '/bind/seleteRate',{  //获取费率
                              params: {
                                  id:this.GLOBAL.id,
                                  productldentif:'PNS66'
                              }
                          }
                          ).then(res => {
                              if (res.data.code == "0000") {
                                  if(res.data.data != null){
                                      var dofee=res.data.data.singlePrice
                                      axios.post(this.host + '/bind/updateRate', this.$qs.stringify({   //更新费率
                                          aisleMerId:merchantNo,
                                          rate:res.data.data.rate,
                                          bankCode:this.defcc.bankCode,
                                          amount:this.GLOBAL.accMul(this.amount,100),
                                          productldentif:"PNS66"//PNS66
                                      })
                                      ).then(res => {
                                          if (res.data.code == "0000") {
                                              axios.post(this.host + '/bind/updateD0fee', this.$qs.stringify({   //更新 D0 费率
                                                  aisleMerId:merchantNo,
                                                  d0Fee:dofee,
                                              })).then(res => {
                                                  if(this.defcc.bank=='' || this.defcc.bank==null || this.defcc.bank==undefined){
                                                    this.defcc.bank='其他银行'
                                                  }
                                                  if (res.data.code == "0000") {
                                                      axios.post(this.host + '/order/pay', this.$qs.stringify({   //支付
                                                          frontCallBackUrl:'https://community.1818pay.cn:1181/yj-jpos/location.html',
                                                          // frontCallBackUrl:'www.baidu.com'
                                                          lng:this.point.lng,//精度
                                                          lat:this.point.lat,//维度
                                                          aisleMerId: merchantNo , 
                                                          id:this.GLOBAL.id,
                                                          productldentif:"PNS66",
                                                          amount:this.GLOBAL.accMul(this.amount,100),
                                                          creditCardNo:this.defcc.bankCard,  //
                                                          creditPhone:this.defcc.reservePhone,  //
                                                          creditCardCode:this.defcc.bankCode,  //
                                                          creditCardName:this.defcc.bank,    //卡归属银行
                                                      })).then(res => {
                                                          if (res.data.code == "0000") {
                                                              Toast.clear();
                                                              // this.GLOBAL.orderNo=res.data.data.orderNo
                                                              // // if(this.GLOBAL.terminal == 'iOS' ){
                                                              // //     window.location=res.data.data.url.payUrl
                                                              // // }else{
                                                              //     this.GLOBAL.payUrl=res.data.data.url.payUrl
                                                              //     this.$router.push({
                                                              //         name:'qrcode'
                                                              //     })
                                                              // // }
                                                               window.location=res.data.data.url.payUrl
                                                          }else{
                                                              Toast.clear();
                                                              return Toast(res.data.msg);
                                                          }
                                                      }).catch(err=>{
                                                          Toast.clear();
                                                          return Toast('请求超时');
                                                      })
                                                  }else{
                                                      Toast.clear();
                                                      return Toast(res.data.msg);
                                                  }
                                              }).catch(err=>{
                                                  Toast.clear();
                                                  return Toast('请求超时');
                                              })
                                          }else{
                                              Toast.clear();
                                              return Toast(res.data.msg);
                                          }
                                      }).catch(err=>{
                                          Toast.clear();
                                          return Toast('请求超时');
                                      })
                                  }else{
                                      Toast.clear();
                                      return Toast('请求超时');
                                  }
                              }else{
                                  Toast.clear();
                                  return Toast(res.data.msg);
                              }
                          }).catch(err=>{
                              Toast.clear();
                              return Toast('请求超时');
                          })
                        }else{
                          Toast.clear();
                          return this.$toast(res.data.msg);
                        }
                      }).catch(err=>{
                        Toast.clear();
                        return this.$toast('请求超时')
                      })
                    }else{
                      // Toast.clear();
                      // queren={
                      //     amount:this.amount,
                      //     scard:this.defsc,  //储蓄卡
                      //     ccard:this.defcc,//信用卡
                      //     merchantNo:merchantNo,
                      // }
                      this.GLOBAL.queren=this.amount
                      // this.$router.push({
                      //     name:'queren',
                      // })
                      axios.get(this.host + '/bind/seleteRate',{  //获取费率
                          params: {
                              id:this.GLOBAL.id,
                              productldentif:'PNS66'
                          }
                      }
                      ).then(res => {
                          if (res.data.code == "0000") {
                              if(res.data.data != null){
                                  var dofee=res.data.data.singlePrice
                                  axios.post(this.host + '/bind/updateRate', this.$qs.stringify({   //更新费率
                                      aisleMerId:merchantNo,
                                      rate:res.data.data.rate,
                                      bankCode:this.defcc.bankCode,
                                      amount:this.GLOBAL.accMul(this.amount,100),
                                      productldentif:"PNS66"//PNS66
                                  })
                                  ).then(res => {
                                      if (res.data.code == "0000") {
                                          axios.post(this.host + '/bind/updateD0fee', this.$qs.stringify({   //更新 D0 费率
                                              aisleMerId:merchantNo,
                                              d0Fee:dofee,
                                          })).then(res => {
                                              if(this.defcc.bank=='' || this.defcc.bank==null || this.defcc.bank==undefined){
                                                this.defcc.bank='其他银行'
                                              }
                                              if (res.data.code == "0000") {
                                                  axios.post(this.host + '/order/pay', this.$qs.stringify({   //支付
                                                      frontCallBackUrl:'https://community.1818pay.cn:1181/yj-jpos/location.html',
                                                      // frontCallBackUrl:'www.baidu.com'
                                                      lng:this.point.lng,//精度
                                                      lat:this.point.lat,//维度
                                                      aisleMerId: merchantNo , 
                                                      id:this.GLOBAL.id,
                                                      productldentif:"PNS66",
                                                      amount:this.GLOBAL.accMul(this.amount,100),
                                                      creditCardNo:this.defcc.bankCard,  //
                                                      creditPhone:this.defcc.reservePhone,  //
                                                      creditCardCode:this.defcc.bankCode,  //
                                                      creditCardName:this.defcc.bank,    //卡归属银行
                                                  })).then(res => {
                                                      if (res.data.code == "0000") {
                                                          Toast.clear();
                                                          // this.GLOBAL.orderNo=res.data.data.orderNo
                                                          // // if(this.GLOBAL.terminal == 'iOS' ){
                                                          // //     window.location=res.data.data.url.payUrl
                                                          // // }else{
                                                          //     this.GLOBAL.payUrl=res.data.data.url.payUrl
                                                          //     this.$router.push({
                                                          //         name:'qrcode'
                                                          //     })
                                                          // // }
                                                           window.location=res.data.data.url.payUrl
                                                      }else{
                                                          Toast.clear();
                                                          return Toast(res.data.msg);
                                                      }
                                                  }).catch(err=>{
                                                      Toast.clear();
                                                      return Toast('请求超时');
                                                  })
                                              }else{
                                                  Toast.clear();
                                                  return Toast(res.data.msg);
                                              }
                                          }).catch(err=>{
                                              Toast.clear();
                                              return Toast('请求超时');
                                          })
                                      }else{
                                          Toast.clear();
                                          return Toast(res.data.msg);
                                      }
                                  }).catch(err=>{
                                      Toast.clear();
                                      return Toast('请求超时');
                                  })
                              }else{
                                  Toast.clear();
                                  return Toast('请求超时');
                              }
                          }else{
                              Toast.clear();
                              return Toast(res.data.msg);
                          }
                      }).catch(err=>{
                          Toast.clear();
                          return Toast('请求超时');
                      })
                    }                    
                  }else{
                    axios.get(this.host + '/Information/select', {   //查询用户图片
                      params: {
                        id: this.GLOBAL.id,
                      }
                    }).then(res => {

                      console.log("res",res)
                      if (res.data.code == "1000") {
                        if(res.data.data==null){
                           Toast.clear();
                          return this.$toast('查询不到图片');
                        }else{
                          let img=[]
                          img.push(res.data.data.userIDCardA)
                          img.push(res.data.data.userIDCardB)
                          img.push(res.data.data.cardImgA)
                          img.push(res.data.data.faceImg)
                          if(res.data.data.userIDCardA == null || res.data.data.userIDCardB == null || res.data.data.cardImgA == null || res.data.data.faceImg ==null){
                            Toast.clear();
                            return this.$toast('资料信息异常，请联系客服')
                          }
                          axios.post(this.host + '/bind/uploadImg', this.$qs.stringify({
                             id: this.GLOBAL.id,
                              aisleMerId:merchantNo,  //通道商户号
                              imgUrl:img[0],  //图片地址
                              imgType:'FRONT_ID_CARD_PHOTO',
                          })   //提交资质接口
                          ).then(res => {
                            
                            if (res.data.code == "0000") {
                              axios.post(this.host + '/bind/uploadImg',    //提交资质接口
                                  this.$qs.stringify({
                                    id: this.GLOBAL.id,
                                    aisleMerId:merchantNo,  //通道商户号
                                    imgUrl:img[1],  //图片地址
                                    imgType:'BACK_ID_CARD_PHOTO',
                                  }),
                              ).then(res => {
                                if (res.data.code == "0000") {
                                  axios.post(this.host + '/bind/uploadImg',this.$qs.stringify({ //提交资质接口
                                     id: this.GLOBAL.id,
                                      aisleMerId:merchantNo,  //通道商户号
                                      imgUrl:img[2],  //图片地址
                                      imgType:'BANK_CARD_IMG',

                                  })).then(res => {
                                   
                                    if (res.data.code == "0000") {
                                      axios.post(this.host + '/bind/uploadImg', this.$qs.stringify({   //提交资质接口
                                       
                                          id: this.GLOBAL.id,
                                          aisleMerId:merchantNo,  //通道商户号
                                          imgUrl:img[3],  //图片地址
                                          imgType:'HAND_ID_CARD_PHOTO',
                                        
                                      })).then(res => {
                                        if (res.data.code == "0000") {
                                          if(settleBankAccountNo!=this.defsc.bankCard){   //判断两个卡号是否一样
                                            axios.post(this.host + '/bind/updateDebitCard', this.$qs.stringify( {   //更改储蓄卡
                                                id: this.GLOBAL.id,
                                                aisleMerId:merchantNo,  //通道商户号
                                                debitCardNo:this.defsc.bankCard,  //新卡号
                                                debitCardPhone:this.defsc.reservePhone,  //新卡预留手机
                                                debitCardBankCode:this.defsc.bankCode,//新卡银行标识
                                            })).then(res => {
                                              if (res.data.code == "0000") {
                                                // queren={
                                                //     amount:this.amount,
                                                //     scard:this.defsc,  //储蓄卡
                                                //     ccard:this.defcc,//信用卡
                                                //     merchantNo:merchantNo,
                                                // }
                                                this.GLOBAL.queren=this.amount
                                                // this.$router.push({
                                                //     name:'queren',
                                                   
                                                // })
                                                axios.get(this.host + '/bind/seleteRate',{  //获取费率
                                                    params: {
                                                        id:this.GLOBAL.id,
                                                        productldentif:'PNS66'
                                                    }
                                                }
                                                ).then(res => {
                                                    if (res.data.code == "0000") {
                                                        if(res.data.data != null){
                                                            var dofee=res.data.data.singlePrice
                                                            axios.post(this.host + '/bind/updateRate', this.$qs.stringify({   //更新费率
                                                                aisleMerId:merchantNo,
                                                                rate:res.data.data.rate,
                                                                bankCode:this.defcc.bankCode,
                                                                amount:this.GLOBAL.accMul(this.amount,100),
                                                                productldentif:"PNS66"//PNS66
                                                            })
                                                            ).then(res => {
                                                                if (res.data.code == "0000") {
                                                                    axios.post(this.host + '/bind/updateD0fee', this.$qs.stringify({   //更新 D0 费率
                                                                        aisleMerId:merchantNo,
                                                                        d0Fee:dofee,
                                                                    })).then(res => {
                                                                        if(this.defcc.bank=='' || this.defcc.bank==null || this.defcc.bank==undefined){
                                                                          this.defcc.bank='其他银行'
                                                                        }
                                                                        if (res.data.code == "0000") {
                                                                            axios.post(this.host + '/order/pay', this.$qs.stringify({   //支付
                                                                                frontCallBackUrl:'https://community.1818pay.cn:1181/yj-jpos/location.html',
                                                                                // frontCallBackUrl:'www.baidu.com'
                                                                                lng:this.point.lng,//精度
                                                                                lat:this.point.lat,//维度
                                                                                aisleMerId: merchantNo , 
                                                                                id:this.GLOBAL.id,
                                                                                productldentif:"PNS66",
                                                                                amount:this.GLOBAL.accMul(this.amount,100),
                                                                                creditCardNo:this.defcc.bankCard,  //
                                                                                creditPhone:this.defcc.reservePhone,  //
                                                                                creditCardCode:this.defcc.bankCode,  //
                                                                                creditCardName:this.defcc.bank,    //卡归属银行
                                                                            })).then(res => {
                                                                                if (res.data.code == "0000") {
                                                                                    Toast.clear();
                                                                                    // this.GLOBAL.orderNo=res.data.data.orderNo
                                                                                    // // if(this.GLOBAL.terminal == 'iOS' ){
                                                                                    // //     window.location=res.data.data.url.payUrl
                                                                                    // // }else{
                                                                                    //     this.GLOBAL.payUrl=res.data.data.url.payUrl
                                                                                    //     this.$router.push({
                                                                                    //         name:'qrcode'
                                                                                    //     })
                                                                                    // // }
                                                                                     window.location=res.data.data.url.payUrl
                                                                                }else{
                                                                                    Toast.clear();
                                                                                    return Toast(res.data.msg);
                                                                                }
                                                                            }).catch(err=>{
                                                                                Toast.clear();
                                                                                return Toast('请求超时');
                                                                            })
                                                                        }else{
                                                                            Toast.clear();
                                                                            return Toast(res.data.msg);
                                                                        }
                                                                    }).catch(err=>{
                                                                        Toast.clear();
                                                                        return Toast('请求超时');
                                                                    })
                                                                }else{
                                                                    Toast.clear();
                                                                    return Toast(res.data.msg);
                                                                }
                                                            }).catch(err=>{
                                                                Toast.clear();
                                                                return Toast('请求超时');
                                                            })
                                                        }else{
                                                            Toast.clear();
                                                            return Toast('请求超时');
                                                        }
                                                    }else{
                                                        Toast.clear();
                                                        return Toast(res.data.msg);
                                                    }
                                                }).catch(err=>{
                                                    Toast.clear();
                                                    return Toast('请求超时');
                                                })
                                              }else{
                                                Toast.clear();
                                                return this.$toast(res.data.msg);
                                              }
                                            }).catch(err=>{
                                              Toast.clear();
                                              return this.$toast('请求超时')
                                            })
                                          }else{
                                            // Toast.clear();
                                            // queren={
                                            //     amount:this.amount,
                                            //     scard:this.defsc,  //储蓄卡
                                            //     ccard:this.defcc,//信用卡
                                            //     merchantNo:merchantNo,
                                            // }
                                            this.GLOBAL.queren=this.amount
                                            // this.$router.push({
                                            //     name:'queren',
                                            // })
                                            axios.get(this.host + '/bind/seleteRate',{  //获取费率
                                                params: {
                                                    id:this.GLOBAL.id,
                                                    productldentif:'PNS66'
                                                }
                                            }
                                            ).then(res => {
                                                if (res.data.code == "0000") {
                                                    if(res.data.data != null){
                                                        var dofee=res.data.data.singlePrice
                                                        axios.post(this.host + '/bind/updateRate', this.$qs.stringify({   //更新费率
                                                            aisleMerId:merchantNo,
                                                            rate:res.data.data.rate,
                                                            bankCode:this.defcc.bankCode,
                                                            amount:this.GLOBAL.accMul(this.amount,100),
                                                            productldentif:"PNS66"//PNS66
                                                        })
                                                        ).then(res => {
                                                            if (res.data.code == "0000") {
                                                                axios.post(this.host + '/bind/updateD0fee', this.$qs.stringify({   //更新 D0 费率
                                                                    aisleMerId:merchantNo,
                                                                    d0Fee:dofee,
                                                                })).then(res => {
                                                                    if(this.defcc.bank=='' || this.defcc.bank==null || this.defcc.bank==undefined){
                                                                      this.defcc.bank='其他银行'
                                                                    }
                                                                    if (res.data.code == "0000") {
                                                                        axios.post(this.host + '/order/pay', this.$qs.stringify({   //支付
                                                                            frontCallBackUrl:'https://community.1818pay.cn:1181/yj-jpos/location.html',
                                                                            // frontCallBackUrl:'www.baidu.com'
                                                                            lng:this.point.lng,//精度
                                                                            lat:this.point.lat,//维度
                                                                            aisleMerId: merchantNo , 
                                                                            id:this.GLOBAL.id,
                                                                            productldentif:"PNS66",
                                                                            amount:this.GLOBAL.accMul(this.amount,100),
                                                                            creditCardNo:this.defcc.bankCard,  //
                                                                            creditPhone:this.defcc.reservePhone,  //
                                                                            creditCardCode:this.defcc.bankCode,  //
                                                                            creditCardName:this.defcc.bank,    //卡归属银行
                                                                        })).then(res => {
                                                                            if (res.data.code == "0000") {
                                                                                Toast.clear();
                                                                                // this.GLOBAL.orderNo=res.data.data.orderNo
                                                                                // // if(this.GLOBAL.terminal == 'iOS' ){
                                                                                // //     window.location=res.data.data.url.payUrl
                                                                                // // }else{
                                                                                //     this.GLOBAL.payUrl=res.data.data.url.payUrl
                                                                                //     this.$router.push({
                                                                                //         name:'qrcode'
                                                                                //     })
                                                                                // // }
                                                                                 window.location=res.data.data.url.payUrl
                                                                            }else{
                                                                                Toast.clear();
                                                                                return Toast(res.data.msg);
                                                                            }
                                                                        }).catch(err=>{
                                                                            Toast.clear();
                                                                            return Toast('请求超时');
                                                                        })
                                                                    }else{
                                                                        Toast.clear();
                                                                        return Toast(res.data.msg);
                                                                    }
                                                                }).catch(err=>{
                                                                    Toast.clear();
                                                                    return Toast('请求超时');
                                                                })
                                                            }else{
                                                                Toast.clear();
                                                                return Toast(res.data.msg);
                                                            }
                                                        }).catch(err=>{
                                                            Toast.clear();
                                                            return Toast('请求超时');
                                                        })
                                                    }else{
                                                        Toast.clear();
                                                        return Toast('请求超时');
                                                    }
                                                }else{
                                                    Toast.clear();
                                                    return Toast(res.data.msg);
                                                }
                                            }).catch(err=>{
                                                Toast.clear();
                                                return Toast('请求超时');
                                            })
                                          }
                                          
                                        }else{
                                            Toast.clear();
                                            return this.$toast(res.data.msg);
                                        }
                                      }).catch(err=>{
                                        Toast.clear();
                                        return this.$toast('资质上传失败，请重试')
                                      })
                                    }else{
                                        Toast.clear();
                                        return this.$toast(res.data.msg);
                                    }
                                  }).catch(err=>{
                                    Toast.clear();
                                    return this.$toast('资质上传失败，请重试')
                                  })
                                }else{
                                    Toast.clear();
                                    return this.$toast(res.data.msg);
                                }
                              }).catch(err=>{
                                Toast.clear();
                                return this.$toast('资质上传失败，请重试')
                              })
                            }else{
                                Toast.clear();
                                return this.$toast(res.data.msg);
                            }
                          }).catch(err=>{
                            Toast.clear();
                            return this.$toast('资质上传失败，请重试')
                          })
                        }
                      }else{
                        Toast.clear();
                        return this.$toast(res.data.message);
                      }
                    }).catch(err=>{
                      Toast.clear();
                      return this.$toast('请求超时')
                    })
                  }
                }else{
                  Toast.clear();
                  return this.$toast(res.data.msg);
                }
              }).catch(err=>{
                Toast.clear();
                return this.$toast('请求超时')
              })
            }
          }else{
             Toast.clear();
            return this.$toast(res.data.msg);
          }
        }).catch(err=>{
          Toast.clear();
          return this.$toast('请求超时')
        })
        
      },
      
    },
    filters: {
      fmtscname: function (fmtscname) {
        // console.log(fmtscname)
        var mccname = {
            ICBC: "工商银行",  
            ABC: "农业银行",  
            BOC: "中国银行",   
            CCB: "建设银行",   
            CMBCHINA: "招商银行",  
            POST: "邮政储蓄",  
            ECITIC: "中信银行",  
            CEB: "光大银行",   
            BOCO: "交通银行",  
            CIB: "兴业银行",   
            CMBC: "民生银行",  
            PINGAN: "平安银行",  
            CGB: "广发银行",   
            HXB: "华夏银行",   
            SPDB: "浦发银行",  
            SHB: "上海银行",   
            BCCB:"北京银行",   
        };
        if(fmtscname != undefined &&fmtscname!=''){
           return mccname[fmtscname];
        }else{
          return '其他银行'
        }
        // if (mccname[fmtscname] == undefined) {
        //   return "";
        // } else {
        //   return mccname[fmtscname];
        // }

      },
      fmtbl: function (bl) {
        return bl.toFixed(2);
      },
      fmtsccardno: function (carno) {
        return (carno + "").slice((carno + "").length - 4);
      },
      fmtccbank: function (banklogo) {
       
        if(banklogo!=undefined&&banklogo!=''){
          return "https://hstatic.1818pay.cn/image/banklogo/62/" + banklogo + ".png";
        }else{
           return imgse;
        }
      },
      fmtcardnomi: function (card) {
        // console.log('card',card)
        if(card!=undefined){
          return card.substr(0, 4) + "********" + card.substr(-4);
        }
      }
    }
  };
</script>